package com.wkm.chainchain.pbft.common;

public enum PBFTMsgType {
    REQUEST(-1, "共识发布"),
    INIT(0, "初始化"),
    GET_VIEW(1, "请求视图"),
    CHANGE_VIEW(2, "变更视图"),
    PRE_PREPARE(3, "预准备阶段"),
    PREPARE(4, "准备阶段"),
    COMMIT(5, "提交阶段"),
    CLIENT_REPLAY(6, "ip消息回复回复阶段");


    private final int code;
    private final String status;

    PBFTMsgType(int code, String status) {
        this.code = code;
        this.status = status;
    }

    public int getCode() {
        return code;
    }

    public String getStatus() {
        return status;
    }

    public static PBFTMsgType getByCode(int code) {
        for (PBFTMsgType value : values()) {
            if (value.getCode() == code) {
                return value;
            }
        }
        return null;
    }
}
